package com.xiong.xtools.springIndicator;

import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;

import com.google.common.collect.Lists;
import com.xiong.xtools.R;
import com.xiong.xtools.springIndicator.viewpager.ScrollerViewPager;

import java.util.List;

import github.chenupt.multiplemodel.viewpager.ModelPagerAdapter;
import github.chenupt.multiplemodel.viewpager.PagerModelManager;
/**
 * Author : 熊文强
 * Time : 2017/9/19
 * Content : 黏连滑动气泡动画
 */
public class SpringIndicatorActivity extends AppCompatActivity {
	ScrollerViewPager viewPager;

	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.activity_spring_indicator);

		viewPager = (ScrollerViewPager) findViewById(R.id.view_pager);
		SpringIndicator springIndicator = (SpringIndicator) findViewById(R.id.indicator);

		PagerModelManager manager = new PagerModelManager();
		manager.addCommonFragment(GuideFragment.class, getBgRes(), getTitles());
		ModelPagerAdapter adapter = new ModelPagerAdapter(getSupportFragmentManager(), manager);
		viewPager.setAdapter(adapter);
		viewPager.fixScrollSpeed();

		// 设置ViewPager
		springIndicator.setViewPager(viewPager);
	}

	private List<String> getTitles(){
		return Lists.newArrayList("1", "2", "3", "4");
	}

	private List<Integer> getBgRes(){
		return Lists.newArrayList(R.mipmap.bg1, R.mipmap.bg2, R.mipmap.bg3, R.mipmap.bg4);
	}

}

